package 代码记录.Bit48天集训;

import java.util.Scanner;

/**1.星际密码
 * 2.数根(已搞定)
 * @author zx
 * @create 2022-05-23 8:48
 */
public class day_25 {
    public static void main2(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int[] arr = new int[n];
            for(int i = 0;i < n;i++){
                arr[i] = sc.nextInt();
            }
        }
    }
    /**
     * @param args 这道题考察大数据处理能力
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String line = sc.nextLine();
            while(line.length() > 1){
                int n = 0;
                for(int i = 0;i < line.length();i++){
                    n += line.charAt(i) - '0';
                }
                line = String.valueOf(n);
            }
            System.out.println(line);
        }
    }
}
